package com.yeyks.commonReference.pojo.param.other.InvoiceInfo;

import cn.hutool.core.collection.CollectionUtil;
import com.yeyks.common.param.consumer.UserIdParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class CreateInvoiceParam extends UserIdParam {

    @ApiModelProperty(value = "抬头类型， 0，个人单位， 1 企业单位")
    @NotNull(message = "抬头类型不能为空")
    @Min(value = 0, message = "抬头类型错误")
    @Max(value = 1, message = "抬头类型错误")
    private Integer headType;
    @ApiModelProperty(value = "发票抬头")
    @NotBlank(message = "发票抬头不能为空")
    @Size(max = 32, message = "发票抬头长度过长")
    private String invoiceHead;
    @ApiModelProperty(value = "税号")
//    @NotBlank(message = "税号不能为空")
//    @Size(max = 32, message = "税号长度过长")
//    @Pattern(regexp = "\\w{1,32}", message = "税号信息有误")
    private String taxId;
    @ApiModelProperty(value = "邮箱")
    @NotBlank(message = "邮箱不能为空")
    @Pattern(regexp = ".*@.*", message = "邮箱信息错误")
    private String email;
    @ApiModelProperty(value = "开票类型  1： 订单开票（c2b）， 2：充值开票（优享VIP）")
    @NotNull(message = "开票类型不能为空")
    @Min(value = 1, message = "开票类型错误")
    @Max(value = 2, message = "开票类型错误")
    private Integer invoiceType;

    @ApiModelProperty(value = "订单号字符串 ,分割")
    @NotBlank(message = "订单号不能为空")
    private String orderNoListStr;

    public CreateInvoiceParam setOrderNoListStr(String orderNoListStr) {
        this.orderNoListStr = orderNoListStr;
        try {
            this.orderNoList = CollectionUtil.newArrayList(orderNoListStr.split(","));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return this;
    }

    @ApiModelProperty(value = "订单号列表", hidden = true)
    private List<String> orderNoList;


}
